from django.http import Http404
from django.shortcuts import render_to_response, get_object_or_404
from django.template import RequestContext
    
from pr_j.models import Project

def index(request, template_name="pr_j/index.html"):
    """
    The index
    """
    projects = Project.objects.all()
    return render_to_response(template_name, {'projects':projects, 'nav_page':'pr_j_index'},
                              context_instance=RequestContext(request))

def concept_index(request, template_name="pr_j/index.html"):
    """
    The concept index
    """
    projects = Project.objects.all()
    return render_to_response(template_name, {'projects':projects, 'concept':True, 'nav_page':'pr_j_concept_index'},
                              context_instance=RequestContext(request))
    
def project(request, slug, template_name="pr_j/project.html"):
    """
    A project in the CMS
    """
    project = get_object_or_404(Project, slug=slug)
    return render_to_response(template_name, {'project':project,},
                              context_instance=RequestContext(request))
